<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/index.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script type="text/javascript" src="js/jquery1.42.min.js"></script>
    <script type="text/javascript" src="js/jquery.SuperSlide.2.1.1.js"></script>
    <title>登录注册</title>
    <script src="https://cdn.bootcss.com/jquery/2.1.2/jquery.min.js"></script>
    <script>
        $(function () {
            $("#subbtn").click(function () {

                var flag = true;

                $("#err_username").html('');
                $("#err_userpasswd").html('');

                var username = $("input[name='username']").val();
                var userpasswd = $("input[name='userpasswd']").val();

                if (username == ''){
                    $("#err_username").html('名称不能为空');
                    //   $("input[name='username']").focus();
                    flag =  false;
                }
                if (userpasswd == ''){
                    $("#err_userpasswd").html('密码不能为空');
                    // $("input[name='userpasswd']").focus();
                    flag =  false;
                }
                if (flag) {
                    $.post('checklogin.php', {username: username, userpasswd: userpasswd}, function (data) {

                        if (data.code == 200) {
                            window.location.href = 'index.php';
                            return;
                        } else if (data.code == 501) {
                            $("#err_username").html(data.message);
                            return;
                        } else if (data.code == 502) {
                            $("#err_userpasswd").html(data.message);
                            return;
                        }

                    }, 'json');
                }
            });
        });


    </script>
    <title>text</title>
    <style>
        #login{
            background:#ffffff;
            width: 330px;
            height:auto;
            overflow:hidden;
            margin:  0 auto;
            margin-top: 10px;
        }

        ipnut.inn{
            width: 300px;
            height:20px;
            padding: 2px 10px;
            border:1px solid #e2e2e2;
        }
        a.subbtn{
            background: #829696;
            color: #333;
            text-decoration: none;
            border:1px solid #e2e2e2;
            width:150px;
            height:30px;
            line-height: 26px;
            overflow:hidden;
            display:block ;
            text-align: center;
            margin:  0 auto;
        }
        label.error{
            font-size:12px ;
            color:#f00;

        }

    </style>
</head>
<body>
<div id="header">
    <h1>个人博客</h1>
    <p>青春是打开了,就合不上的书。人生是踏上了，就回不了头的路，爱情是扔出了，就收不回的赌注。</p>
</div>
    <div id="say">
        <div class="weizi">
        <div class="wz_text">当前位置：<a href="#">首页</a>><h1>用户登录</h1></div>
        </div>
        <form name="login" action="text.php"method="post">
        <ul class="say_box">
            <div class="sy">
                <div id="login">


                        <p>
                            用户:<input type="text" name="username"id="username"class="inn">
                            <label class="error" id="err_username"></label>
                        </p>
                </div>


            <span class="dateview"><=</span>
        </ul>
        <ul class="say_box">
            <div class="sy">
                <div id="login">

                    <p>
                        密码:<input type="password"name="userpasswd" id="userpasswd"class="inn">
                        <label class="error" id="err_userpasswd"></label>
                </div>
            </div>
            <span class="dateview"><=</span>
        </ul>
        <ul class="say_box">
            <div class="sy">
                <div id="login">
                    </p>
                    <a href="javascript:void(0);" class="subbtn" id="subbtn">登录</a>


                </div>
            </div>
            <span class="dateview"><=</span>
        </ul>
        </form>
    </div>
</div>
</body>
</html>